Skip to content

feat: quick polls, an availability link with no account - #51

Merged
musa-kal merged 21 commits into
mainfrom
feat/quick-polls-no-account
Nov 23, 2026
Merged

musa-kal merged 21 commits into
mainfrom
feat/quick-polls-no-account

Conversation

@musa-kal

@musa-kal musa-kal commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Intent

Quick polls (issue 50): anyone can make an availability poll from the landing page with no account, share its link, and everyone who opens it adds their times and sees the best ones. A poll takes at most 15 people, and the entry on the landing page is meant to be easy to find without shouting.

Deliberate decisions:

  • The hard cap on people per poll is 15 (the issue suggested 20). Default 10, minimum 2. This is the owner's explicit choice.
  • Quick polls have their own additive tables (quick_polls, quick_poll_answers, quick_poll_slots) with RLS on, no policies and no grants to anon or authenticated. They have no group, event or auth user. All access is through five security definer RPCs that anon may call: create_quick_poll, quick_poll_preview, set_quick_poll_availability, close_quick_poll, delete_quick_poll. This is recorded in docs/adr/0022.
  • Unlike guest links, the poll preview returns every answer with names (or null names when the poll has names off, shown as "Anonymous N" from the seat number). Everyone holding the link is a peer; there is no group to protect.
  • Answer tokens are made by the browser (a Web Crypto UUID, stored before the first save) and the server stores only the sha256, so a retried first save edits the same seat instead of taking a second one. The owner chose this after a review finding; a missing or malformed token raises invalid_quick_poll_token. The server still issues the creator token, and the creator's token is also their answer token. The creator's seat is not reserved and counts toward the cap.
  • Expiry is 24 hours or 7 days only. The window is at most 14 days, slots are 30 minutes in the UI (the SQL allows 30 or 60).
  • Rate limiting lives in the database because the app is a static site that talks straight to Supabase: 5 polls an hour per client keyed on the first x-forwarded-for entry, and 200 an hour overall. The per-client key is known to be spoofable by a client; this is accepted and documented in ADR 22 and docs/security.md, with the overall limit as the backstop. Turnstile is out of scope (it needs an account key a person must set up).
  • The create log lives in private.quick_poll_creates, not on the poll row, so deleting a poll does not return quota.
  • private.event_slots now delegates to a new private.grid_slots so plans and polls share one grid rule. The only wording change is the invalid_slot detail text.
  • "Live" results are a 15 second refetch while the tab is visible plus refetch on focus. No Realtime, because anon has no table access.
  • Both close (results stay readable until expiry) and delete (gone now) exist for the creator.
  • A retried create_quick_poll after a lost reply makes a second poll; accepted, the orphan expires.
  • The unused isQuickPollTtl helper was removed on purpose.
  • The browser memory is { token, name } with no creator flag; the preview's is_creator is the authority.
  • Shared guest page pieces were extracted (link memory, public page frame, window fields, sent card, share sheet) and the guest page was moved onto them, rather than copying.
  • /p/* is noindex (meta tag plus public/_headers X-Robots-Tag). The existing guest link route /a/$code has no noindex on main; that is a known gap left out of scope.
  • No Help topic link on the quick poll pages: the guide page in Fermulate/potluck-docs does not exist yet and ships after this merges, per the repo contract.
  • Some strings shared with the guest page stay under the guests.* i18n keys rather than being renamed across five languages.
  • The landing page entry is a saffron card under the hero buttons plus one quiet text link under the plans feature. It is meant to be noticeable but in the page's existing design language, without new colours, badges or animation.
  • The e2e helper clears private.quick_poll_creates on the local database through docker exec psql so repeated runs do not trip the 5 an hour limit. Local stack only; the limit itself is unchanged.

What Changed

  • Database: a new additive migration adds quick_polls, quick_poll_answers and quick_poll_slots (RLS on, no policies, no grants to anon or authenticated) plus five anon-callable security definer RPCs: create_quick_poll, quick_poll_preview, set_quick_poll_availability, close_quick_poll and delete_quick_poll. Polls take at most 15 people (default 10, minimum 2), expire after 24 hours or 7 days, and creation is rate limited in the database through private.quick_poll_creates. private.event_slots now delegates to a new private.grid_slots so plans and polls share one grid rule. Covered by supabase/tests/36_quick_polls.test.sql and the updated 01_schema.test.sql.
  • Web app: two new signed-out routes, /poll (create) and /p/$code (answer, see results, share, close or delete), with /p/* marked noindex (meta tag plus public/_headers). The landing page gains a card under the hero buttons and a text link under the plans feature. Results refetch every 15 seconds while the tab is visible and on focus. Shared pieces (link memory, public page frame, window fields, sent card, share sheet) were extracted and the guest page now uses them. Adds packages/api queries and mutations, packages/core limits, strings in all five languages, unit tests and a Playwright journey (e2e/quick-polls.spec.ts).
  • Docs: ADR 22 (quick polls without accounts), plus updates to docs/architecture.md, docs/security.md, docs/testing.md, docs/development.md, the README feature list, AGENTS.md files, and the regenerated agent-map.json, schema snapshot, database types and route tree.

Closes #50

Credits: Musa (musa-kal), Ferrin (Ferrin-Y) and Noor (noorelmosrati)

Risk Assessment

⚠️ Medium: No blocking defects found and both fix rounds hold up under tracing, but the change is large and adds five anon-callable definer RPCs whose abuse limits rest on documented, accepted tradeoffs (spoofable per-client key, global cap as backstop).

Testing

Built the web app for production, served it on an isolated port (4391) against the local Supabase stack (which already carried this branch's quick poll migration; the quick polls pgTAP file passed against it), then ran the repo's quick poll journey spec plus a throwaway Playwright spec of seven adversarial and visual scenarios on desktop-chromium and mobile-chromium. All passed: landing card to create page, 15 person cap in the UI and the database, two people answering without accounts, live refresh, edit, close, full, delete, anonymous names, rate limit, token rules, no table access for anon, and a lost first-save reply on the last seat. Screenshots of each UI state were captured. Not covered: mobile-webkit, the X-Robots-Tag header from public/_headers (applied by the static host, not by vite preview; the noindex meta tag was checked in the live page), and the PR and commit metadata requirements, which belong to other phases. One first run of my own lost-reply scenario failed on a wrong button label in my test (the product correctly offered "Update my times"); the test was corrected and passed. The preview server was stopped, the build output and the temporary spec were removed from the worktree, and the create log on the local database was cleared.

  • Live validation: ✅ go - 10 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Signed-out visitor sees the saffron 'Find a time, no sign-up' card under the hero buttons on the landing page and it opens the create page at /poll ✅ pass live evidence-scenarios.spec.ts 'landing card leads to the create page' on desktop-chromium and mobile-chromium; 01-landing-desktop-chromium.png, 01-landing-mobile-chromium.png
Create page: people stepper defaults to 10, stops at 15 and at 2; a poll made with 15 opens at /p/<code> with the share card and a noindex meta tag ✅ pass live Same test; 02-create-max15-.png, 03-poll-ready-.png
Server cap: a 15 person poll takes 15 answers and refuses the 16th with quick_poll_full; creating with 16 or 1 people raises invalid_quick_poll_people; a 30 day expiry raises invalid_quick_poll_ttl ✅ pass live evidence-scenarios.spec.ts 'server cap' (anon RPC calls to the local Supabase API)
Full journey: create from the landing page, creator and a second person answer without accounts, the creator's page picks up the new answer without reload, the friend edits on return, the creator clos… ✅ pass live apps/web/e2e/quick-polls.spec.ts first test on desktop-chromium and mobile-chromium
A full poll turns a new visitor away (no name field) but still shows everyone's times ✅ pass live apps/web/e2e/quick-polls.spec.ts second test on desktop-chromium and mobile-chromium
Tokens: resending a first save with the same browser token keeps one seat; short or empty tokens raise invalid_quick_poll_token; an answer token cannot close or delete (not_allowed); anon cannot read… ✅ pass live evidence-scenarios.spec.ts 'tokens' test
Rate limit: the sixth poll created within an hour from one client is refused with quick_poll_rate_limited ✅ pass live evidence-scenarios.spec.ts 'rate limit' test
Names off: answers come back with null names and seats 1 and 2, the page says answers are anonymous, shows no name field and never shows the submitted names ✅ pass live evidence-scenarios.spec.ts 'names off' test; 04-anonymous-*.png
Last seat with the save reply lost: after a 17 second wait (past a refetch) the page keeps the painted times and the form instead of 'This poll is full', and the retry lands on the same seat (2 of 2 a… ✅ pass live evidence-scenarios.spec.ts 'last seat, reply lost' test; 05-lost-reply-form-kept-.png, 06-lost-reply-retry-sent-.png
Delete: a non-creator sees no close or delete controls; the creator deletes the poll and the link then shows 'No poll here' for the friend and the preview RPC returns quick_poll_not_found ✅ pass live evidence-scenarios.spec.ts 'the creator deletes the poll' test; 07-deleted-creator-.png, 08-deleted-friend-.png
/p/* responses carry the X-Robots-Tag: noindex header from public/_headers on the deployed static host ⏸️ untested no public/_headers is read by the production static host, not by vite preview, so the header cannot be observed locally; no local emulator of the host's header rules is in the repo, and production is out…

Landing page with quick poll card (desktop)

Landing page with quick poll card (mobile)

Landing page, full length (desktop)

Create page at the 15 person cap (desktop)

Create page at the 15 person cap (mobile)

New poll with share card (desktop)

New poll with share card (mobile)

Anonymous poll with two answers and heatmap (desktop)

Lost reply on the last seat: form and painted times kept (desktop)

Lost reply: retry saved on the same seat (desktop)

Lost reply: retry saved on the same seat (mobile)

After delete, creator's view (desktop)

After delete, friend's view of the dead link (desktop)

Evidence: Throwaway Playwright spec that drove the extra scenarios
import { t } from '@potluck/i18n'
import { createClient } from '@supabase/supabase-js'
import { randomUUID } from 'node:crypto'
import { answerQuickPoll, clearQuickPollCreates, quickPoll } from './support/api'
import { stackEnv } from './support/env'
import { expect, test, unique } from './support/fixtures'

const DIR = process.env.EVID!

function anon() {
  const env = stackEnv()
  return createClient(env.url, env.publishableKey, {
    auth: { persistSession: false, autoRefreshToken: false },
  })
}

async function code(run: () => Promise<unknown>): Promise<string> {
  try {
    await run()
    return 'no_error'
  } catch (error) {
    return (error as { code?: string; message?: string }).code ?? (error as Error).message
  }
}

test.describe.configure({ mode: 'serial' })

test('landing card leads to the create page; 15 is the most people', async ({ openAs }, info) => {
  clearQuickPollCreates()
  const p = info.project.name
  const page = await openAs(null)
  await page.goto('/')
  const card = page.getByRole('link', {
    name: new RegExp(`^${t('app.landing.quickPoll.title')}`),
  })
  await expect(card).toBeVisible()
  await page.screenshot({ path: `${DIR}/01-landing-${p}.png` })
  await page.screenshot({ path: `${DIR}/01-landing-full-${p}.png`, fullPage: true })
  await card.click()
  await expect(page).toHaveURL(/\/poll$/)
  await expect(
    page.getByRole('heading', { level: 1, name: t('quickPolls.create.title') }),
  ).toBeVisible()
  const title = unique('Cap')
  await page.getByLabel(t('quickPolls.create.titleLabel')).fill(title)
  // Default is 10.
  await expect(page.getByText(/up to 10 people/)).toBeVisible()
  const more = page.getByRole('button', { name: t('quickPolls.create.morePeople') })
  if (!(await more.isVisible())) await page.getByText(t('quickPolls.create.more')).click()
  for (let i = 0; i < 5; i++) await more.click()
  await expect(more).toBeDisabled()
  await expect(page.getByText(/up to 15 people/)).toBeVisible()
  const fewer = page.getByRole('button', { name: t('quickPolls.create.fewer') })
  await page.screenshot({ path: `${DIR}/02-create-max15-${p}.png`, fullPage: true })
  for (let i = 0; i < 13; i++) await fewer.click()
  await expect(fewer).toBeDisabled()
  await expect(page.getByText(/up to 2 people/)).toBeVisible()
  for (let i = 0; i < 13; i++) await more.click()
  await page.getByRole('button', { name: t('quickPolls.create.submit') }).click()
  await expect(page.getByRole('heading', { level: 1, name: title })).toBeVisible()
  await expect(page).toHaveURL(/\/p\/[\w-]+$/)
  await expect(page.getByText(t('quickPolls.page.readyTitle'))).toBeVisible()
  await expect(page.locator('meta[name="robots"]')).toHaveAttribute('content', 'noindex')
  await page.screenshot({ path: `${DIR}/03-poll-ready-${p}.png`, fullPage: true })
})

test('server cap: 15 seats fill, the 16th is refused; 16 and 1 are not valid sizes', async () => {
  const poll = await quickPoll({ maxPeople: 15 })
  for (let i = 0; i < 15; i++) await answerQuickPoll(poll.code, `P${i + 1}`)
  expect(await code(() => answerQuickPoll(poll.code, 'P16'))).toBe('quick_poll_full')
  const { data } = await anon().rpc('quick_poll_preview', { code: poll.code })
  expect(data[0].status).toBe('full')
  expect(data[0].answers).toHaveLength(15)
  expect(await code(() => quickPoll({ maxPeople: 16 }))).toBe('invalid_quick_poll_people')
  expect(await code(() => quickPoll({ maxPeople: 1 }))).toBe('invalid_quick_poll_people')
  expect(await code(() => quickPoll({ ttl: '30d' as never }))).toBe('invalid_quick_poll_ttl')
})

test('tokens: a resent first save keeps one seat; bad tokens and strangers are refused', async () => {
  const poll = await quickPoll({ maxPeople: 2 })
  const token = randomUUID()
  await answerQuickPoll(poll.code, 'Retry', token)
  await answerQuickPoll(poll.code, 'Retry', token)
  const client = anon()
  const { data } = await client.rpc('quick_poll_preview', { code: poll.code, token })
  expect(data[0].status).toBe('open')
  expect(data[0].answers).toHaveLength(1)
  expect(data[0].answers[0].mine).toBe(true)
  expect(await code(() => answerQuickPoll(poll.code, 'Bad', 'short'))).toBe(
    'invalid_quick_poll_token',
  )
  expect(await code(() => answerQuickPoll(poll.code, 'Bad', ''))).toBe('invalid_quick_poll_token')
  // An answer token is not the creator token.
  const close = await client.rpc('close_quick_poll', { code: poll.code, token })
  expect(close.error?.message).toBe('not_allowed')
  const del = await client.rpc('delete_quick_poll', { code: poll.code, token })
  expect(del.error?.message).toBe('not_allowed')
  // No table access for anon: only the RPCs.
  for (const table of ['quick_polls', 'quick_poll_answers', 'quick_poll_slots']) {
    const read = await client.from(table).select('*').limit(1)
    expect(read.error, table).not.toBeNull()
    expect(read.data, table).toBeNull()
  }
})

test('rate limit: the sixth poll in an hour from one client is refused', async () => {
  const first = await quickPoll()
  expect(first.code).toBeTruthy()
  const client = anon()
  const payload = {
    title: 'Limit',
    timezone: 'UTC',
    window_start: new Date(Date.now() + 86_400_000).toISOString().slice(0, 10),
    window_end: new Date(Date.now() + 86_400_000).toISOString().slice(0, 10),
    day_start_minute: 600,
    day_end_minute: 720,
    duration_minutes: 60,
    slot_minutes: 30,
    ttl: '24h',
    names_required: true,
    max_people: 10,
  }
  for (let i = 0; i < 4; i++) {
    const made = await client.rpc('create_quick_poll', { payload })
    expect(made.error, `poll ${i + 2}`).toBeNull()
  }
  const sixth = await client.rpc('create_quick_poll', { payload })
  expect(sixth.error?.message).toBe('quick_poll_rate_limited')
  clearQuickPollCreates()
})

test('names off shows Anonymous N', async ({ openAs }, info) => {
  const title = unique('Anon')
  const poll = await quickPoll({ title, namesRequired: false })
  await answerQuickPoll(poll.code, 'ignored-one')
  await answerQuickPoll(poll.code, 'ignored-two')
  const page = await openAs(null)
  await page.goto(`/p/${poll.code}`)
  await expect(page.getByRole('heading', { level: 1, name: title })).toBeVisible()
  await expect(page.getByText(t('quickPolls.page.answered', { count: 2, max: 10 }))).toBeVisible()
  await expect(page.getByText('ignored-one')).toHaveCount(0)
  await expect(page.getByLabel(t('quickPolls.page.nameLabel'))).toHaveCount(0)
  await page.screenshot({ path: `${DIR}/04-anonymous-${info.project.name}.png`, fullPage: true })
  const { data } = await anon().rpc('quick_poll_preview', { code: poll.code })
  expect(data[0].answers.map((a: { name: unknown }) => a.name)).toEqual([null, null])
  expect(data[0].answers.map((a: { seat: number }) => a.seat)).toEqual([1, 2])
})

test('last seat, reply lost: the retry lands on the same seat, not "full"', async ({
  openAs,
}, info) => {
  const title = unique('Lost')
  const poll = await quickPoll({ title, maxPeople: 2 })
  await answerQuickPoll(poll.code, 'First')
  const page = await openAs(null)
  let dropped = 0
  await page.route('**/rest/v1/rpc/set_quick_poll_availability', async (route) => {
    if (dropped === 0) {
      dropped += 1
      // The server stores the answer, the browser never hears back.
      await route.fetch()
      await route.abort('connectionreset')
    } else {
      await route.continue()
    }
  })
  await page.goto(`/p/${poll.code}`)
  await page.getByLabel(t('quickPolls.page.nameLabel')).fill('Second')
  const painter = page.getByRole('grid', { name: t('quickPolls.page.gridLabel', { title }) })
  await painter
    .getByRole('gridcell', { name: /not set/ })
    .first()
    .focus()
  await page.keyboard.press('Space')
  await page.keyboard.press('Shift+ArrowDown')
  const submit = page.getByRole('button', { name: t('quickPolls.page.submit') })
  await submit.click()
  await expect.poll(() => dropped).toBe(1)
  // The seat is taken server side already.
  const { data } = await anon().rpc('quick_poll_preview', { code: poll.code })
  expect(data[0].status).toBe('full')
  // Wait past a refetch: the form must still be here, not the "full" card.
  await page.waitForTimeout(17_000)
  await expect(page.getByRole('heading', { name: t('quickPolls.page.fullTitle') })).toHaveCount(0)
  // The page now knows the stored answer is this visitor's: painted times kept, save offered again.
  const again = page.getByRole('button', { name: t('quickPolls.page.update') })
  await expect(again).toBeVisible()
  await expect(page.getByText(t('availability.mySlots', { count: 2 }))).toBeVisible()
  await page.screenshot({ path: `${DIR}/05-lost-reply-form-kept-${info.project.name}.png` })
  await again.click()
  await expect(page.getByText(t('quickPolls.page.sentTitle', { name: 'Second' }))).toBeVisible()
  await expect(page.getByText(t('quickPolls.page.answered', { count: 2, max: 2 }))).toBeVisible()
  await page.screenshot({
    path: `${DIR}/06-lost-reply-retry-sent-${info.project.name}.png`,
    fullPage: true,
  })
  const after = await anon().rpc('quick_poll_preview', { code: poll.code })
  expect(after.data[0].answers).toHaveLength(2)
})

test('the creator deletes the poll; the link is dead for everyone', async ({ openAs }, info) => {
  clearQuickPollCreates()
  const title = unique('Gone')
  const creator = await openAs(null)
  await creator.goto('/poll')
  await creator.getByLabel(t('quickPolls.create.titleLabel')).fill(title)
  await creator.getByRole('button', { name: t('quickPolls.create.submit') }).click()
  await expect(creator.getByRole('heading', { level: 1, name: title })).toBeVisible()
  const path = new URL(creator.url()).pathname
  const pollCode = path.split('/').pop()!

  const friend = await openAs(null)
  await friend.goto(path)
  await expect(friend.getByRole('heading', { level: 1, name: title })).toBeVisible()
  // Someone who did not make the poll gets no creator controls.
  await expect(friend.getByRole('button', { name: t('quickPolls.page.delete') })).toHaveCount(0)
  await expect(friend.getByRole('button', { name: t('quickPolls.page.close') })).toHaveCount(0)

  await creator.getByRole('button', { name: t('quickPolls.page.delete') }).click()
  await creator
    .getByRole('dialog', { name: t('quickPolls.page.deleteTitle') })
    .getByRole('button', { name: t('quickPolls.page.delete') })
    .click()
  await expect(creator.getByText(title)).toHaveCount(0)
  await creator.screenshot({ path: `${DIR}/07-deleted-creator-${info.project.name}.png` })
  await friend.reload()
  await expect(
    friend.getByRole('heading', { name: t('quickPolls.ended.notFoundTitle') }),
  ).toBeVisible()
  await friend.screenshot({ path: `${DIR}/08-deleted-friend-${info.project.name}.png` })
  const gone = await anon().rpc('quick_poll_preview', { code: pollCode })
  expect(gone.error?.message).toBe('quick_poll_not_found')
})
Evidence: Final Playwright runs
desktop-chromium evidence spec: 5 passed on first run, remaining 2 (lost reply, delete) passed after correcting the test's button label
mobile-chromium quick-polls.spec.ts + evidence spec: 9 passed
desktop-chromium quick-polls.spec.ts: 2 passed
pgTAP 36_quick_polls.test.sql: PASS

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 4 issues (3 warnings, 1 info)
  • ⚠️ apps/web/src/features/quick-polls/poll-page.tsx:451 - A first save whose reply is lost can leave the page telling the visitor the poll is full and their times were not saved, when the answer was in fact stored. The token a new visitor makes is written to storage and to the madeToken ref (lines 451-456), but PollPage's memory state stays null until onSaved, so the 15 second refetch (line 67) keeps calling quick_poll_preview without a token. Sequence: a visitor takes the last seat, the save commits server side, the reply is lost (onError, not a STOPPED code, form stays). The next refetch returns status full with their own answer shown as someone else's (mine false), editing turns false (line 190), AnswerForm unmounts and the StatusCard shows fullTitle plus the unsaved notice (lines 251-256). The retry the browser-made token exists for is no longer reachable without a reload. With storage blocked, the unmount also drops madeToken, so even a reload cannot recover the seat. When the seat is not the last one the same gap shows the visitor's saved answer as another person's row until they retry. Fix at the shared boundary: lift the made token into PollPage state when it is created (before save.mutate), without clearing unsaved, so every preview call carries it and the server answers open with mine true. placeholderData already covers the query key change.

🔧 Fix applied.
3 warnings still open:

  • ⚠️ apps/web/src/features/quick-polls/poll-page.tsx:451 - A first save whose reply is lost can leave the page telling the visitor the poll is full and their times were not saved, when the answer was in fact stored. The token a new visitor makes is written to storage and to the madeToken ref (lines 451-456), but PollPage's memory state stays null until onSaved, so the 15 second refetch (line 67) keeps calling quick_poll_preview without a token. Sequence: a visitor takes the last seat, the save commits server side, the reply is lost (onError, not a STOPPED code, form stays). The next refetch returns status full with their own answer shown as someone else's (mine false), editing turns false (line 190), AnswerForm unmounts and the StatusCard shows fullTitle plus the unsaved notice (lines 251-256). The retry the browser-made token exists for is no longer reachable without a reload. With storage blocked, the unmount also drops madeToken, so even a reload cannot recover the seat. When the seat is not the last one the same gap shows the visitor's saved answer as another person's row until they retry. Fix at the shared boundary: lift the made token into PollPage state when it is created (before save.mutate), without clearing unsaved, so every preview call carries it and the server answers open with mine true. placeholderData already covers the query key change.
  • ⚠️ apps/web/src/features/quick-polls/poll-page.tsx:90 - Introduced by fix round 1 (commit 5624686). onToken (line 462) switches the preview query to a token-keyed key at submit time. That new query has no data of its own; placeholderData only covers it while its status is pending (query-core 5.106 queryObserver: placeholder applies only when status === &#39;pending&#39;). If its first fetch fails after the 2 retries, preview.data is undefined and preview.isError is true, so line 90 swaps the whole page for the 'Lost the signal' screen and unmounts Poll and AnswerForm. Sequence: a new visitor paints times and submits on a connection that is up but failing (the exact case the browser-made token exists for); the save fails and shows its error in the form; about 3 seconds later the token-keyed preview gives up, the form and every painted time are gone, and after Retry the form comes back empty. Before round 1 the key did not change until onSaved, so a failed refetch kept the last data and the form (the existing test 'keeps the poll and the times being painted when a refresh fails' only covers the unchanged-key case). Fix: make the token-keyed query start with the view already on screen, for example seed it with queryClient.setQueryData(quickPollQueries.preview(supabase, code, token).queryKey, view) right before onToken(made), or keep the last good view in PollPage and fall back to it when preview.data is undefined, so a failed refetch never drops a poll that was already showing.
  • ⚠️ apps/web/src/features/quick-polls/poll-page.tsx:419 - The post-save queryClient.fetchQuery(..., staleTime: 0) does not force a fresh read when a fetch for that key is already in flight: Query.fetch without cancelRefetch returns the in-flight promise (query-core 5.106 query.js fetch). Fix round 1 (commit 5624686) made this reachable on every first save: onToken starts the token-keyed preview fetch at the same moment save.mutate goes out, so when the save reply lands before that preview reply, fetchQuery resolves with a preview the server may have read before the save committed. Result: onSaved sets mode to viewing, but mine is undefined, so neither the SentCard (line 270) nor the form (line 290) renders, the visitor's answer is missing from the heatmap, and for the creator the 'Your poll is ready' card stays. It heals at the next 15 second refetch, but until then the page gives no sign the answer was saved and no way to edit. Before round 1 the token key was new at this point, so the fetch was always fresh. Sibling in the same change: an edit by a returning visitor whose save reply lands while the 15 second interval refetch (line 70) is in flight shows the old slots after 'Sent'. Fix: cancel any in-flight fetch first (await queryClient.cancelQueries({ queryKey: quickPollQueries.preview(supabase, code, next.token).queryKey }) before fetchQuery), or use queryClient.refetchQueries({ queryKey, exact: true }), whose default cancelRefetch: true restarts the fetch.

🔧 Fix applied.
4 issues (3 warnings, 1 info) still open:

  • ⚠️ apps/web/src/features/quick-polls/poll-page.tsx:451 - A first save whose reply is lost can leave the page telling the visitor the poll is full and their times were not saved, when the answer was in fact stored. The token a new visitor makes is written to storage and to the madeToken ref (lines 451-456), but PollPage's memory state stays null until onSaved, so the 15 second refetch (line 67) keeps calling quick_poll_preview without a token. Sequence: a visitor takes the last seat, the save commits server side, the reply is lost (onError, not a STOPPED code, form stays). The next refetch returns status full with their own answer shown as someone else's (mine false), editing turns false (line 190), AnswerForm unmounts and the StatusCard shows fullTitle plus the unsaved notice (lines 251-256). The retry the browser-made token exists for is no longer reachable without a reload. With storage blocked, the unmount also drops madeToken, so even a reload cannot recover the seat. When the seat is not the last one the same gap shows the visitor's saved answer as another person's row until they retry. Fix at the shared boundary: lift the made token into PollPage state when it is created (before save.mutate), without clearing unsaved, so every preview call carries it and the server answers open with mine true. placeholderData already covers the query key change.
  • ⚠️ apps/web/src/features/quick-polls/poll-page.tsx:90 - Introduced by fix round 1 (commit 5624686). onToken (line 462) switches the preview query to a token-keyed key at submit time. That new query has no data of its own; placeholderData only covers it while its status is pending (query-core 5.106 queryObserver: placeholder applies only when status === &#39;pending&#39;). If its first fetch fails after the 2 retries, preview.data is undefined and preview.isError is true, so line 90 swaps the whole page for the 'Lost the signal' screen and unmounts Poll and AnswerForm. Sequence: a new visitor paints times and submits on a connection that is up but failing (the exact case the browser-made token exists for); the save fails and shows its error in the form; about 3 seconds later the token-keyed preview gives up, the form and every painted time are gone, and after Retry the form comes back empty. Before round 1 the key did not change until onSaved, so a failed refetch kept the last data and the form (the existing test 'keeps the poll and the times being painted when a refresh fails' only covers the unchanged-key case). Fix: make the token-keyed query start with the view already on screen, for example seed it with queryClient.setQueryData(quickPollQueries.preview(supabase, code, token).queryKey, view) right before onToken(made), or keep the last good view in PollPage and fall back to it when preview.data is undefined, so a failed refetch never drops a poll that was already showing.
  • ⚠️ apps/web/src/features/quick-polls/poll-page.tsx:419 - The post-save queryClient.fetchQuery(..., staleTime: 0) does not force a fresh read when a fetch for that key is already in flight: Query.fetch without cancelRefetch returns the in-flight promise (query-core 5.106 query.js fetch). Fix round 1 (commit 5624686) made this reachable on every first save: onToken starts the token-keyed preview fetch at the same moment save.mutate goes out, so when the save reply lands before that preview reply, fetchQuery resolves with a preview the server may have read before the save committed. Result: onSaved sets mode to viewing, but mine is undefined, so neither the SentCard (line 270) nor the form (line 290) renders, the visitor's answer is missing from the heatmap, and for the creator the 'Your poll is ready' card stays. It heals at the next 15 second refetch, but until then the page gives no sign the answer was saved and no way to edit. Before round 1 the token key was new at this point, so the fetch was always fresh. Sibling in the same change: an edit by a returning visitor whose save reply lands while the 15 second interval refetch (line 70) is in flight shows the old slots after 'Sent'. Fix: cancel any in-flight fetch first (await queryClient.cancelQueries({ queryKey: quickPollQueries.preview(supabase, code, next.token).queryKey }) before fetchQuery), or use queryClient.refetchQueries({ queryKey, exact: true }), whose default cancelRefetch: true restarts the fetch.
  • ℹ️ apps/web/src/features/quick-polls/poll-page.tsx:427 - Residual edge in the round 2 code, noted for awareness only. When a first save succeeds but the read right after it fails all three tries (line 428, caught at 429), onSaved still switches to viewing while the cached view (the one seeded by onToken at line 134) has no mine answer. Neither the SentCard (line 276) nor the form (line 296) renders, so the page gives no sign the answer was saved until the next 15 second refresh gets through; it then shows the Sent card on its own. Narrow (the network must drop between the save reply and the read) and self-healing, so no action is needed.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 10 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Signed-out visitor sees the saffron 'Find a time, no sign-up' card under the hero buttons on the landing page and it opens the create page at /poll ✅ pass live evidence-scenarios.spec.ts 'landing card leads to the create page' on desktop-chromium and mobile-chromium; 01-landing-desktop-chromium.png, 01-landing-mobile-chromium.png
Create page: people stepper defaults to 10, stops at 15 and at 2; a poll made with 15 opens at /p/<code> with the share card and a noindex meta tag ✅ pass live Same test; 02-create-max15-.png, 03-poll-ready-.png
Server cap: a 15 person poll takes 15 answers and refuses the 16th with quick_poll_full; creating with 16 or 1 people raises invalid_quick_poll_people; a 30 day expiry raises invalid_quick_poll_ttl ✅ pass live evidence-scenarios.spec.ts 'server cap' (anon RPC calls to the local Supabase API)
Full journey: create from the landing page, creator and a second person answer without accounts, the creator's page picks up the new answer without reload, the friend edits on return, the creator clos… ✅ pass live apps/web/e2e/quick-polls.spec.ts first test on desktop-chromium and mobile-chromium
A full poll turns a new visitor away (no name field) but still shows everyone's times ✅ pass live apps/web/e2e/quick-polls.spec.ts second test on desktop-chromium and mobile-chromium
Tokens: resending a first save with the same browser token keeps one seat; short or empty tokens raise invalid_quick_poll_token; an answer token cannot close or delete (not_allowed); anon cannot read… ✅ pass live evidence-scenarios.spec.ts 'tokens' test
Rate limit: the sixth poll created within an hour from one client is refused with quick_poll_rate_limited ✅ pass live evidence-scenarios.spec.ts 'rate limit' test
Names off: answers come back with null names and seats 1 and 2, the page says answers are anonymous, shows no name field and never shows the submitted names ✅ pass live evidence-scenarios.spec.ts 'names off' test; 04-anonymous-*.png
Last seat with the save reply lost: after a 17 second wait (past a refetch) the page keeps the painted times and the form instead of 'This poll is full', and the retry lands on the same seat (2 of 2 a… ✅ pass live evidence-scenarios.spec.ts 'last seat, reply lost' test; 05-lost-reply-form-kept-.png, 06-lost-reply-retry-sent-.png
Delete: a non-creator sees no close or delete controls; the creator deletes the poll and the link then shows 'No poll here' for the friend and the preview RPC returns quick_poll_not_found ✅ pass live evidence-scenarios.spec.ts 'the creator deletes the poll' test; 07-deleted-creator-.png, 08-deleted-friend-.png
/p/* responses carry the X-Robots-Tag: noindex header from public/_headers on the deployed static host ⏸️ untested no public/_headers is read by the production static host, not by vite preview, so the header cannot be observed locally; no local emulator of the host's header rules is in the repo, and production is out…
  • pnpm exec supabase test db supabase/tests/000_setup.test.sql supabase/tests/36_quick_polls.test.sql (pass; confirms the local stack runs this branch's SQL)
  • pnpm build in apps/web with local Supabase env and VITE_APP_URL=http://localhost:4391 (exit 0), then pnpm preview --port 4391 --strictPort
  • E2E_PORT=4391 pnpm exec playwright test e2e/quick-polls.spec.ts --project=desktop-chromium (2 passed)
  • E2E_PORT=4391 pnpm exec playwright test e2e/quick-polls.spec.ts e2e/zz-evidence.spec.ts --project=mobile-chromium (9 passed)
  • E2E_PORT=4391 pnpm exec playwright test e2e/zz-evidence.spec.ts --project=desktop-chromium (first run 5 passed, 1 failed on my own wrong button label, 1 skipped; after correcting the test, the remaining 2 passed)
  • Temporary spec kept as evidence-scenarios.spec.ts in the evidence directory; viewed landing, anonymous poll and lost-reply screenshots by eye
🔧 **Document** - 1 issue found → auto-fixed ✅
  • ℹ️ apps/web/AGENTS.md:21 - The route rule names only /a/$code (guest links) as signed out; /poll and /p/$code are now signed out routes too. The line is incomplete, not wrong, and AGENTS.md may only be edited to correct wrong facts, so it was left alone. A person may want to add the two quick poll routes there. docs/architecture.md and docs/development.md already state it.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Issues

Closes #50

musa-kal and others added 21 commits November 22, 2026 18:22
Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
…d share sheet

Guest links and quick polls both remember a token per code, sit in the same
public frame with the same dead ends, ask for a date window and hours, and
share a link. These pieces move out of the guest page and the plan form so
both screens use one copy:

- lib/link-memory.ts: a per-code record in localStorage that survives blocked
  storage; guest-token.ts becomes one instance of it.
- shell/public-page.tsx: PublicFrame, DeadEnd, NextSteps, Notice and Pitch.
- plans/window-fields.tsx and plans/window.ts: the date window and daily
  hours fields with an optional day cap, and the duration options.
- invites/share.ts: shareLink, which shareInvite and shareGuestLink now use.
- The heatmap and best times take an optional nameOf for full names.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
…h guest links

The guest page's "times in" card and its list of days, hours and length
move to features/availability, and the token and name record becomes
parseTokenMemory in lib/link-memory, so quick polls reuse them.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
Create page, poll page, dead ends and the landing page entry, in English,
German, Spanish, French and Portuguese.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
/poll makes a poll from sensible defaults with names, the seat cap and
expiry folded under More options. /p/$code renders from the poll status
plus a viewing or editing mode: paint and send, everyone's heatmap and
ranked best times (core rankSlots), share and copy, a sent card to edit
from, full and closed notices, close and delete for the creator, dead ends
for expired and unknown codes, and a sign up pitch for visitors without an
account. Results refresh every 15 seconds while the tab is visible and on
focus. Both routes work signed out; /p/* is kept out of search engines
with a robots meta tag and an X-Robots-Tag header.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
A saffron date chip under the hero buttons, "Find a time, no sign-up",
with the same tile as The night below it, and a quiet link under The
night itself.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
Make a poll from the landing page signed out, copy the link, two browsers
answer, the creator sees the second answer without a reload, the friend
edits, the creator closes it. A full poll turns a new person away. The
create page and a poll page join the accessibility audit. Each test empties
the local create log first, the rate limit itself is unchanged.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
…st save keeps one seat

A first save whose reply was lost left the browser without a token, so the
retry made a second answer under the same name: the first seat was orphaned,
counted twice in best times and the heatmap, and used up the cap.

The poll page now makes a random token (Web Crypto) for a visitor without one
and keeps it in link memory, and in component state when storage is blocked,
before the first save goes out. set_quick_poll_availability takes that token:
one the poll does not know makes a new answer under it, a known one edits it,
the creator token works as before, and a missing or malformed token is
refused with invalid_quick_poll_token (22023). The return shape is unchanged
and hands back the token as sent.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
…r typed

With maxDays, the first day handler pulled the last day back for every value
it saw. Clearing the field threw a RangeError (addDays on an empty day), and
typing a year by keyboard passed through days like 0002-06-02, which clamped
the last day and then collapsed the window to one day.

The pull back now waits for a real first day from today on; anything else
passes through and leaves the last day alone, and the submit check refuses
the window. The plan form, which has no maxDays, is unchanged.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
@musa-kal
musa-kal merged commit e4d2ff0 into main Nov 23, 2026
7 checks passed
@musa-kal
musa-kal deleted the feat/quick-polls-no-account branch November 23, 2026 06:27

This branch was successfully deployed

1 active deployment
preview — 714390d4 Deployed Nov 23, 2026 by musa-kal via Deploy web to Cloudflare #136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick polls: create and share an availability link with no account

1 participant